package com.cxx.java.spring.ioc;

import com.cxx.java.spring.ioc.demo.Demo1;
import com.cxx.java.spring.ioc.demo.Demo2;
import com.cxx.java.spring.ioc.demo.Demo3;
import com.cxx.java.spring.ioc.demo.Demo4;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class App {
    public static void a(){
        ApplicationContext beans=new ClassPathXmlApplicationContext("applicationContext.xml");
        Object obj1 = beans.getBean("d1");
        Demo1 d1 = beans.getBean(Demo1.class);
        System.out.println(obj1);
        System.out.println(d1);
        System.out.println(obj1 == d1);
    }

    public static void b(){
        ApplicationContext beans=new ClassPathXmlApplicationContext("applicationContext.xml");
        Demo2 d2 = beans.getBean(Demo2.class);
        System.out.println(d2);
    }

    public static void c(){
        ApplicationContext beans=new ClassPathXmlApplicationContext("applicationContext.xml");
        Demo3 d3 = beans.getBean(Demo3.class);
        System.out.println(d3);
    }

    public static void d(){
        ApplicationContext beans=new ClassPathXmlApplicationContext("applicationContext.xml");
        Demo4 d4=beans.getBean(Demo4.class);
        System.out.println(d4);
    }
    public static void main(String[] args) {
//        a();
//        b();
//        c();
        d();
    }
}
